//
// Created by Felix on 24-4-23.
//

#ifndef GAZE_DTOS_HPP
#define GAZE_DTOS_HPP

#include <oatpp/core/Types.hpp>
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/data/mapping/type/Object.hpp"

#include "dto/AuthResponseDto.hpp"
#include "dto/UserResponseDto.hpp"
#include "dto/CameraResponseDto.hpp"

#define DTO_TEMPLATE(CLASS_NAME, T) \
        class CLASS_NAME : public MessageDto<T > { \
            DTO_INIT(CLASS_NAME, MessageDto<T > /* Extends */) \
        };

#include OATPP_CODEGEN_BEGIN(DTO)

template<typename T=oatpp::Any>
class MessageDto : public oatpp::DTO {

    DTO_INIT(MessageDto, DTO /* Extends */)

    DTO_FIELD_INFO(statusCode) {
        info->description = "状态代码";
        info->required = true;
    } // status_code
    DTO_FIELD(Int32, statusCode, "status_code");

    DTO_FIELD_INFO(status) {
        info->description = "简短的状态文本; OK 或者 ERROR";
        info->required = true;
    } // status
    DTO_FIELD(String, status);

    DTO_FIELD_INFO(message) {
        info->description = "详细的信息";
        info->required = true;
    } // message
    DTO_FIELD(String, message);

    DTO_FIELD_INFO(data) {
        info->description = "返回数据";
        info->required = true;
    } // data
    DTO_FIELD(T, data);

};

template<class T=oatpp::Any>
class PageResponseDto : public oatpp::DTO {
    DTO_INIT(PageResponseDto, DTO)

    DTO_FIELD_INFO(current) {
        info->description = "当前页码";
        info->required = true;
    } // current
    DTO_FIELD(Int32, current);

    DTO_FIELD_INFO(pageSize) {
        info->description = "每页条数";
        info->required = true;
    } // page_size
    DTO_FIELD(Int32, pageSize, "page_size");

    DTO_FIELD_INFO(total) {
        info->description = "一共条数";
        info->required = true;
    } // total
    DTO_FIELD(Int32, total);

    DTO_FIELD_INFO(items) {
        info->description = "数据列表";
        info->required = true;
    } // items
    DTO_FIELD(Vector < T >, items);
};

DTO_TEMPLATE(MessageDtoComposeAuthDto, oatpp::Object<AuthResponseDto>)

DTO_TEMPLATE(MessageDtoComposeVector, oatpp::Vector<oatpp::Any>)

DTO_TEMPLATE(MessageDtoComposeUserResponseDto, oatpp::Object<UserResponseDto>)

DTO_TEMPLATE(
        MessageDtoComposePageOfUsers,
        oatpp::Object<PageResponseDto<oatpp::Object<UserResponseDto> > >
)

DTO_TEMPLATE(MessageDtoComposeCameraResponseDto, oatpp::Object<CameraResponseDto>)

DTO_TEMPLATE(
        MessageDtoComposePageOfCameras,
        oatpp::Object<PageResponseDto<oatpp::Object<CameraResponseDto> > >
)

#include OATPP_CODEGEN_END(DTO)

#endif //GAZE_DTOS_HPP
